package cn.lastjune.dao;

import java.io.Serializable;
import java.util.List;

import cn.lastjune.util.Page;

public interface GenericDao<T, ID extends Serializable>
{

	/**
	 * Save new entity
	 * 
	 * @param entity entity object
	 * @return the entity's ID
	 */
	public ID add(T entity);

	/**
	 * update entity
	 * 
	 * @param entity entity object
	 */
	public void update(T entity);

	/**
	 * delete entity
	 * 
	 * @param entity entity object
	 */
	public void delete(T entity);

	/**
	 * delete entity by id
	 * 
	 * @param id entity id
	 */
	public void delete(ID id);

	/**
	 * Get all entities
	 * 
	 * @return entity list
	 */
	public List<T> getAll();

	/**
	 * get all entities by page
	 * 
	 * @param page pagination helper object
	 * @return pagination object which includes entity list
	 */
	public  Page<T> getPageAll(Page<T> page);

	/**
	 * Get the entity by id
	 * 
	 * @param id entity id
	 * @return entity entity object
	 */
	public T get(ID id);


}
